﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="EditEmployee.aspx.cs" Inherits="MonkeyWarranty.Web.InstantTickets.EditEmployee" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <title>
        <%=Resources.GlobalStrings.InstantTicketForm %> - <%=Resources.GlobalStrings.WarrantyEmployees %></title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2><%=Resources.GlobalStrings.InstantTicketForm %>: <%=Resources.GlobalStrings.WarrantyEmployees %></h2>
    <p></p>
    <span class="failureNotification">
        <asp:Literal ID="lblErrorMessage" runat="server"></asp:Literal></span>
    <div style="min-width: 960px;">
        <fieldset class="register">
            <div style="float: left;margin-right: 50px;">
                <p>
                    <asp:HiddenField ID="hidEmployeeId" runat="server" />
                    <label><%=Resources.GlobalStrings.Employees%></label>
                    <asp:TextBox ID="txtEmployeeName" runat="server" ReadOnly="True" CssClass="textEntry name"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtEmployeeName"
                        CssClass="failureNotification" ValidationGroup="AddNew">(*)</asp:RequiredFieldValidator>
                    <a href="javascript:void(0);" onclick="javascript:SelectEmployee();">Select</a>
                </p>
                <div id="employees-dialog-form" title="<%=Resources.GlobalStrings.EmployeesList %>">
                    <div id="EmployeesTableContainer"></div>
                </div>
                
                <p>
                    <label><%=Resources.GlobalStrings.StartDate %></label><asp:TextBox ID="txtStartDate" runat="server" CssClass="textEntry date"></asp:TextBox>
                </p>
            </div>
            <div style="float: left;">
                <p><label><%=Resources.GlobalStrings.Description %></label><asp:TextBox ID="txtDescription" runat="server" TextMode="MultiLine" CssClass="textEntry description"></asp:TextBox></p>
                <p><label><%=Resources.GlobalStrings.Note %></label><asp:TextBox ID="txtNote" TextMode="MultiLine" runat="server" CssClass="textEntry description"></asp:TextBox></p>
            </div>
        </fieldset>
    </div>
    <p></p>
    <div>
        <input id="btnCancel" type="button" value="<%=Resources.GlobalStrings.Cancel %>"
            class="submitButton" onclick="javascript:window.location='Edit.aspx?id=<%=TicketId %>#tabs-3';" />
        <asp:Button ID="btnSave" runat="server" Text="<%$ Resources:GlobalStrings, Save %>"
            CssClass="submitButton" ValidationGroup="AddNew" OnClick="btnSave_Click" />
    </div>
    
    <script type="text/javascript">
        $(function () {
            $("#menu-instant").addClass("active");

            $("#<%=txtEmployeeName.ClientID %>").prop("disabled", true);
            $("#<%=txtStartDate.ClientID %>").calendar();

            $("#dialog:ui-dialog").dialog("destroy");
            $("#employees-dialog-form").dialog({
                autoOpen: false,
                height: 400,
                width: 800,
                modal: true
            });

            //Prepare jtable plugin
            $('#EmployeesTableContainer').jtable({
                paging: false,
                pageSize: 10,
                sorting: false,
                actions: {
                    listAction: '../Employees/List.aspx/EmployeeList'
                },
                fields: {
                    Id: {
                        key: true,
                        create: false,
                        edit: false,
                        list: false
                    },
                    Code: {
                        title: '<%=Resources.GlobalStrings.Code %>'
                    },
                    Name: {
                        title: '<%=Resources.GlobalStrings.Name %>',
                        width: '20%',
                        display: function (data) {
                            return '<a href="javascript:void(0);" onclick="javascript:EmployeeSelect({Id:' + data.record.Id +
                            ',Code:\'' + data.record.Code + '\'' +
                                ',Name:\'' + data.record.Name + '\'' +
                                    '});">' + data.record.Name + '</a>';
                        }
                    }
                }
            });
        });
    </script>
    
    <script type="text/javascript">
        function EmployeeSelect(employee) {
            $("#employees-dialog-form").dialog("close");
            $("#<%=hidEmployeeId.ClientID %>").val(employee.Id);
            $("#<%=txtEmployeeName.ClientID %>").val(employee.Name);
        }

        function SelectEmployee() {
            // load data
            $("#employees-dialog-form").dialog("open");
            $('#EmployeesTableContainer').jtable('load');
        }
    </script>
</asp:Content>
